package com.aizuda.boot.modules.business.template.entity.vo;


import com.aizuda.boot.modules.file.domain.vo.FileVO;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Data
@Schema(description = "合同模板详情响应")
public class ContractTemplateDetailRespDTO {

    @Schema(description = "模板ID")
    private Integer templateId;

    @Schema(description = "模板名称")
    private String templateName;

    @Schema(description = "适用范围类型：department、personnel")
    private String scopeType;

    @Schema(description = "适用范围值（JSON：部门ID或人员ID列表）")
    private String scopeValue;

    @Schema(description = "创建时是否可编辑")
    private Boolean editableWhenCreating;

    @Schema(description = "使用说明")
    private String usageInstructions;

    @Schema(description = "合同模板文件URL")
    private String templateFileUrl;

    @Schema(description = "合同模板文件名称")
    private String templateFileName;

    @Schema(description = "合同模板文件信息")
    private FileVO fileInfo;

    @Schema(description = "状态：draft 草稿，published 发布")
    private String status;

    @Schema(description = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createdAt;

    @Schema(description = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updatedAt;

    @Schema(description = "一级合同类型ID")
    private Integer contractTypeLevel1;

    @Schema(description = "二级合同类型ID")
    private Integer contractTypeLevel2;

    @Schema(description = "三级合同类型ID")
    private Integer contractTypeLevel3;

    @Schema(description = "模块列表")
    private List<ModuleDTO> modules;

    @Data
    @Schema(description = "模块信息")
    public static class ModuleDTO {
        @Schema(description = "模块ID")
        private Integer moduleId;

        @Schema(description = "模块名称")
        private String moduleName;

        @Schema(description = "模块描述")
        private String moduleDescription;

        @Schema(description = "模块排序")
        private Integer moduleOrder;

        @Schema(description = "字段列表")
        private List<FieldDTO> fields;
    }

    @Data
    @Schema(description = "字段信息")
    public static class FieldDTO {
        @Schema(description = "字段ID")
        private Long fieldId;

        @Schema(description = "父级字段ID")
        private Long parentFieldId;

        @Schema(description = "字段名称")
        private String fieldName;

        @Schema(description = "字段类型（TEXT,NUMBER,DATE,SELECT,CHECKBOX,PERSON,DEPARTMENT,GROUP等）")
        private String fieldType;

        @Schema(description = "字段选项（JSON格式存储）")
        private Map<String, Object> fieldOptions;

        @Schema(description = "字段描述")
        private String fieldDescription;

        @Schema(description = "是否必填")
        private Boolean isRequired;

        @Schema(description = "是否启用")
        private Boolean isEnabled;

        @Schema(description = "是否系统字段")
        private Boolean isSystem;

        @Schema(description = "数字类型保留小数位数")
        private Integer decimalPlaces;

        @Schema(description = "数字类型单位")
        private String unit;

        @Schema(description = "字段排序")
        private Integer fieldOrder;

        @Schema(description = "子字段列表")
        private List<FieldDTO> children;
    }
} 